Reduce per-row overhead in session recv and putValue dispatch#195
Open
TheDistributor wants to merge 1 commit into
Open
Reduce per-row overhead in session recv and putValue dispatch#195TheDistributor wants to merge 1 commit into
TheDistributor wants to merge 1 commit into
Conversation
Streamline the data-ingestion pipeline and outbound parameter encoding loop by eliminating high-overhead memory copies, optimizing primitive type comparisons, and increasing TCP window throughput. Detailed changes: - session: Request an opportunistic 1 MiB socket receive buffer (SO_RCVBUF) to minimize fragmented kernel reads across heavy wire payload streams. - session: Rewrite `__readFully` to pre-allocate a single message-sized bytearray. Populate it directly using zero-copy `sock.recv_into()` on a slicing memoryview, replacing an iterative chunk concatenation loop. - encodedsession: Update `recv()` and input stream targets to return and use raw mutable bytearray buffers directly, cutting down an extra copy. - encodedsession: Refactor `putValue` to use rapid pointer-level exact type comparisons (`type(v) is X`) for common database primitives (int, str, float, bool) before falling back to heavier hierarchy-aware `isinstance()` checks for the long tail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
recv_into, and drop the redundant bytes->bytearray copy in _exchangeMessages
fewer reads
direct type check before falling through to the slower isinstance chain
Nominal performance change on its own, but lays the groundwork for future changes.